<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.util.*,javax.naming.*,java.sql.*,javax.sql.*" %>
<%@ page import="com.simple.util.common.*" %>
<%@ include file="../include/head.jspf"%> 

<c:set var="passwordLengthMax" value="<%=Constants.USER_PASSWORD_LENGTH_MAX %>"></c:set>
<c:set var="passwordLengthMin" value="<%=Constants.USER_PASSWORD_LENGTH_MIN %>"></c:set>   

<head>
<title>东方易云后台管理系统</title>

<script>
function confirm(){
	var errorMsg = "";
	errorMsg += sl_check($("#password")[0], '<spring:message code="web.user.self.editpassword.original.password" />', 20, 1);
	errorMsg += sl_check($("#passwordNew")[0], '<spring:message code="web.user.self.editpassword.new.password" />', 20, 1);
	errorMsg += sl_check($("#passwordConfirm")[0], '<spring:message code="web.user.self.editpassword.confirm.password" />', 20, 1);
	
	if(errorMsg != ""){
		alert(errorMsg);
	}else{
		var expr = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{<c:out value="${passwordLengthMin}"/>,<c:out value="${passwordLengthMax}"/>}$/;
		var passwordNew = $("#passwordNew").val();
		
		if(!expr.test(passwordNew)){
 			alert('<spring:message code="message.user.self.editpassword.new.password.wrong" arguments="${passwordLengthMin },${passwordLengthMax }"/>');
 			return;
 		}
		
		$('#editPassword').submit();
	}
}

function cancel(){
	$('#cancelEditPassword').submit();
}

$(document).ready(function(){
	if($("#editSuccess").val() == "Y"){
		alert('<spring:message code="message.user.self.editpassword.sucess" />');
		$('#editPasswordSuccess').submit();
	}
});

</script>
</head>

<body>
<input type="hidden" id="editSuccess" name="editSuccess" value="<c:out value='${editSuccess}' />"/>
<form action="/user/self/editPasswordSubmit" id="editPassword" method="post">
					
					<div class="clear"></div>
					<p>
						<label><spring:message code="web.user.self.editpassword.original.password" />:</label>
						<input class="text-input" type="password"   value="<c:out value='${password}' />" name='password' id='password'/>
					</p>
					<p>
						<label><spring:message code="web.user.self.editpassword.new.password" />:</label>
						<input class="text-input" type="password"   value="<c:out value='${passwordNew}' />"  name='passwordNew' id='passwordNew'/>
					</p>
					<p>
						<label><spring:message code="web.user.self.editpassword.confirm.password" />:</label>
						<input class="text-input" type="password"  value="<c:out value='${passwordConfirm}' />"  name='passwordConfirm' id='passwordConfirm'/>
					</p>
					<div class="clear"></div>
					<p>
						
						<a class="button" href="javascript:void(0);" onclick="confirm();"><spring:message code="web.user.self.editpassword.confirm" /></a> &nbsp;&nbsp;<a class="button" onclick="cancel()"><spring:message code="web.user.self.editpassword.cancel" /></a>
					</p>
					
</form>

<form action="/user/self/cancelEditPasswordSubmit" name="cancelEditPassword" id="cancelEditPassword" method="post">
</form>

<form action="/user/self/editPasswordSuccessSubmit" name="editPasswordSuccess" id="editPasswordSuccess" method="post">
</form>

</body>

</html>
